<?php
header('content-type:application/json;charset=UTF-8');

$connect = mysqli_connect('127.0.0.1', 'root', 'root', 'tp6');
$sql = 'SELECT COUNT(sex) as value,sex as name from yg group by sex';
$query = mysqli_query($connect, $sql);
$data = mysqli_fetch_all($query);


$sex = [];


echo json_encode(['code' => 1, 'msg' => '查询成功', 'data' => [
    'sex' => $data,

]
]);